home *** CD-ROM | disk | FTP | other *** search
/ 3D Games - Real-time Rend…ng & Software Technology / 3D Games - Real-time Rendering & Software Technology.iso / flysdk / plugin / ship / ship.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-28  |  14.7 KB  |  760 lines

  1. #include "game.h"
  2.  
  3. ship::ship() 
  4.     type=TYPE_SHIP;
  5.     lasthitfrom=-1;
  6.     lasthittime=0;
  7.     flag=0;
  8.     flag2=0;
  9.     flag3=0;
  10.     points=0; 
  11.     player=0;
  12.     abtime=0;
  13.     rotvel.null(); 
  14.     rotforce.null(); 
  15.     mouserot.null(); 
  16.     dynlight.null();
  17.     firesel=0;
  18. }
  19.  
  20. int ship::message(vector& p,float rad,int msg,int param,void *data)
  21. {
  22.     if (msg==FLYOBJM_DAMAGE)
  23.     {
  24.         if (directx->mpmode!=FLYMP_CLIENT && (flag3&0x20000)==0)
  25.             {
  26.             float len;
  27.             mp_data2 msg;
  28.  
  29.             msg.v=pos-p;
  30.             len=msg.v.length();
  31.             if (len>rad || len<SMALL)
  32.                 return 0;
  33.  
  34.             flyengine->excludecollision=this;
  35.             if(flyengine->collision_test(flyengine->bsp, p, pos))
  36.                 {
  37.                 flyengine->excludecollision=0;
  38.                 return 0;
  39.                 }
  40.             flyengine->excludecollision=0;
  41.  
  42.             lasthittime=flyengine->cur_time;
  43.             lasthitfrom=param;
  44.  
  45.             msg.f=*((float *)data);
  46.             msg.v*=msg.f/(len*100.0f);
  47. //            msg.f=*((float *)data)*(1-len/rad);
  48. //            msg.v*=msg.f/(len*100.0f);
  49.             force+=msg.v;
  50.             shield-=msg.f;
  51.             msg.type=FLYMP_MSG_DAMAGE;
  52.             msg.from=directx->players[player].dpid;
  53.  
  54.             directx->send_message((mp_msg *)&msg,sizeof(mp_data2));
  55.  
  56.             if (directx->mpmode==FLYMP_NOMP)
  57.                 flyengine->filter.x+=msg.f>1.0f?1.0f:msg.f;
  58.             }
  59.     }
  60.     else
  61.     if (msg==FLYOBJM_ILLUM)
  62.     {
  63.         float fac=(p-pos).length()/rad;
  64.         if (fac<1.0f)
  65.             dynlight+=*((vector *)data)*(1.0f-fac);
  66.     }
  67.  
  68.     return 1;
  69. }
  70.  
  71. int ship::step(int dt)
  72. {
  73.     float len;
  74.  
  75.     switch( directx->mpmode )
  76.     {
  77.     case FLYMP_SERVER:
  78.         {
  79.         if (player==0)
  80.             {
  81.             life=-1;
  82.             flyengine->cam=source;
  83.             flyengine->player=source;
  84.             directx->players[0].data=0;
  85.             return 0;
  86.             }
  87.  
  88.         if (shield<0 && flag2==0)
  89.             {
  90.             flag2=exptime;
  91.             mp_send_pos(
  92.                 FLYMP_MSG_KILL,
  93.                 (lasthitfrom>=0)?directx->players[lasthitfrom].dpid:-1);
  94.             }
  95.  
  96.         if (flag2==0 || flag2==exptime)
  97.             {
  98.             len=vel.length();
  99.             if (len>0)
  100.                 {
  101.                 vel/=len;
  102.                 if (flag2==0)
  103.                     {
  104.                     len-=dt*veldamp;
  105.                     if (len<0) len=0;
  106.  
  107.                     if (len>maxvel+speedboost)
  108.                         len=maxvel+speedboost;
  109.                     }
  110.                 vel*=len;
  111.                 }
  112.  
  113.             if (shield<0 && flag2==exptime)
  114.                 force.z-=0.0005f;
  115.  
  116.             flyengine->excludecollision=this;
  117.             particle::step(dt);
  118.             flyengine->excludecollision=0;
  119.             }
  120.  
  121.         if (flag2)
  122.             if (flag2==exptime)
  123.                 if (flyengine->hitobj)
  124.                     {
  125.                     flag2-=dt;
  126.                     mp_send_pos(
  127.                         FLYMP_MSG_EXPLODE,
  128.                         (lasthitfrom>=0)?directx->players[lasthitfrom].dpid:-1);
  129.                     remove_from_bsp();
  130.                     }
  131.                 else { ; }
  132.             else 
  133.                 if (flag2>dt)
  134.                     flag2-=dt;
  135.                 else
  136.                     {
  137.                     pos=source->pos;
  138.                     add_to_bsp();
  139.                     vel.null();
  140.                     align_z(vector(0,0,1));
  141.                     rotate(rot);
  142.                     shield=((ship *)source)->shield;
  143.                     flag2=0;
  144.                     flag3=0;
  145.                     }
  146.  
  147.         if (flag3)
  148.             {
  149.             int i=flag3&0xffff;
  150.             if (i<dt)
  151.                 flag3=0;
  152.             else 
  153.                 flag3=(flag3&0xffff0000)|(i-dt);
  154.             }
  155.  
  156.         force.null();
  157.         life=1;
  158.         }
  159.         break;
  160.     case FLYMP_NOMP:
  161.         if (shield<0 && flag2==0)
  162.             {
  163.             flag2=exptime;
  164.             expcam.pos=pos;
  165.             expcam.node=node;
  166.             *((local_system *)&expcam)=*((local_system *)this);
  167.             }
  168.     case FLYMP_CLIENT:
  169.         {
  170.         if (flag2==0 || flag2==exptime)
  171.             {
  172.             if (player==0)
  173.                 {
  174.                 if (flag2==0)
  175.                     check_keys(dt);
  176.  
  177.                 rotvel+=rotforce;
  178.                 rotforce.x=rotforce.y=rotforce.z=0;
  179.                 rotate(mouserot);
  180.                 mouserot.x=mouserot.y=0;
  181.  
  182.                 len=rotvel.length();
  183.                 if (len>0)
  184.                     {
  185.                     rotvel/=len;
  186.                     len-=dt*angulardamp;
  187.                     if (len<0) len=0;
  188.                     if (len>angularmaxvel) len=angularmaxvel;
  189.                     rotvel*=len;
  190.                     rotate(rotvel*(float)dt);
  191.                     }
  192.                 }
  193.  
  194.             len=vel.length();
  195.             if (len>0)
  196.                 {
  197.                 vel/=len;
  198.                 if (flag2==0)
  199.                     {
  200.                     len-=dt*veldamp;
  201.                     if (len<0) len=0;
  202.  
  203.                     if (len>maxvel+speedboost)
  204.                         len=maxvel+speedboost;
  205.                     }
  206.                 vel*=len;
  207.                 }
  208.  
  209.             if (shield<0 && flag2==exptime)
  210.                 force.z-=0.0005f;
  211.  
  212.             flyengine->excludecollision=this;
  213.             particle::step(dt);
  214.             flyengine->excludecollision=0;
  215.             }
  216.  
  217.         if (flag2)
  218.             if (flag2==exptime)
  219.                 if (directx->mpmode==FLYMP_NOMP && flyengine->hitobj)
  220.                     {
  221.                     if (exp) 
  222.                         exp->do_explode(pos,Z,player);
  223.                     flag2-=dt;
  224.                     remove_from_bsp();
  225.                     }
  226.                 else { ; }
  227.             else 
  228.                 if (flag2>dt)
  229.                     flag2-=dt;
  230.                 else
  231.                     {
  232.                     pos=source->pos;
  233.                     add_to_bsp();
  234.                     vel.null();
  235.                     align_z(vector(0,0,1));
  236.                     rotate(rot);
  237.                     shield=((ship *)source)->shield;
  238.                     flag2=0;
  239.                     flag3=0;
  240.                     }
  241.  
  242.         if (flag3)
  243.             {
  244.             int i=flag3&0xffff;
  245.             if (i<dt)
  246.                 flag3=0;
  247.             else 
  248.                 flag3=(flag3&0xffff0000)|(i-dt);
  249.             }
  250.  
  251.         force.null();
  252.         life=1;
  253.  
  254.         if (flag&0x10 && englight)
  255.             {
  256.             englight->pos=pos+Z*engpos;
  257.             flyengine->stepobj=englight;
  258.             englight->step(dt);
  259.             }
  260.         
  261.         if (spot && (flag&0x100))
  262.             spot->reposition(this);
  263.         }
  264.         break;
  265.     }
  266.     
  267.     if (player==0)
  268.         directx->set_listener(&pos.x,0,&Y.x,&Z.x);
  269.  
  270.     return 1;
  271. }
  272.  
  273. void ship::draw()
  274. {
  275.     if (objmesh==0) 
  276.         return;
  277.     if (player==0 && flag2!=exptime)
  278.         return;
  279.     if (flag2 && flag2!=exptime)
  280.         return;
  281.     
  282.     // init dynamic light
  283.     if (flyengine->hwlights)
  284.         {
  285.         objmesh->color.vec(1,1,1,1);
  286.         dynlights.init_draw(this);
  287.         }
  288.     else if (node)
  289.         {
  290.         objmesh->color=node->color+dynlight;
  291.         dynlight.null();
  292.         }
  293.  
  294.     // draw ship and shield
  295.     glPushMatrix();
  296.     glTranslatef(pos.x,pos.y,pos.z);
  297.     glMultMatrixf((float *)&mat);
  298.     if (flag3&SHIP_FLAG3_INVISIBLE)
  299.         objmesh->color.w=invistransp;
  300.     else objmesh->color.w=1.0;
  301.     objmesh->draw();
  302.     if (shieldmesh)
  303.         if ((flag3&SHIP_FLAG3_INVENSIBLE) || flyengine->cur_time-lasthittime<500 || (flag2==exptime))
  304.         {
  305.         glDepthMask(GL_FALSE);
  306.         glBlendFunc(GL_ONE, GL_ONE);
  307.         if (flag2==exptime)
  308.             {
  309.             shieldmesh->color=killcolor;
  310.             shieldmesh->color.w=1.0f;
  311.             }
  312.         else
  313.         if (flag3&SHIP_FLAG3_INVENSIBLE)
  314.             {
  315.             shieldmesh->color=invencolor;
  316.             shieldmesh->color.w=1.0f;
  317.             }
  318.         else 
  319.             {
  320.             float t=1.0f-(flyengine->cur_time-lasthittime)/500.0f;
  321.             shieldmesh->color=hitcolor*t;
  322.             shieldmesh->color.w=t;
  323.             }
  324.         shieldmesh->scrollu=shieldmesh->scrollv=(flyengine->cur_time%750)/750.0f;
  325.         shieldmesh->draw();
  326.         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  327.         glDepthMask(GL_TRUE);
  328.         }
  329.     glPopMatrix();
  330.  
  331.     // end dynamic lights
  332.     if (flyengine->hwlights)
  333.         dynlights.end_draw();
  334.  
  335.     // draw ship engine light
  336.     if (flag&0x10 && englight)
  337.         {
  338.         englight->pos=pos+Z*engpos;
  339.         englight->draw();
  340.         }
  341.  
  342.     // draw ship engine halo
  343.     if (enghalo && (flag3&SHIP_FLAG3_INVISIBLE)==0)
  344.         {
  345.         enghalo->pos=pos+Z*engpos;
  346.         enghalo->color.w=vel.length()/maxvel*0.6f+0.2f;
  347.         if (enghalo->color.w>0.6f) 
  348.             enghalo->color.w=0.6f;
  349.         enghalo->draw();
  350.         }
  351. }
  352.  
  353. int ship::get_custom_param_desc(int i,param_desc *pd)
  354. {
  355.     if (pd==0)
  356.         return 33;
  357.     else 
  358.     switch(i)
  359.     {
  360.         case 0:
  361.             pd->type='p';
  362.             pd->data=&display;
  363.             strcpy(pd->name,"display");
  364.             break;
  365.         case 1:
  366.             pd->type='f';
  367.             pd->data=&speedboost0;
  368.             strcpy(pd->name,"speedboost");
  369.             break;
  370.         case 2:
  371.             pd->type='f';
  372.             pd->data=&shield;
  373.             strcpy(pd->name,"shield");
  374.             break;
  375.         case 3:
  376.             pd->type='f';
  377.             pd->data=&maxshield;
  378.             strcpy(pd->name,"maxshield");
  379.             break;
  380.         case 4:
  381.             pd->type='f';
  382.             pd->data=&maxvel;
  383.             strcpy(pd->name,"maxvel");
  384.             break;
  385.         case 5:
  386.             pd->type='f';
  387.             pd->data=&veldamp;
  388.             strcpy(pd->name,"veldamp");
  389.             break;
  390.         case 6:
  391.             pd->type='f';
  392.             pd->data=&angularmaxvel;
  393.             strcpy(pd->name,"angularmaxvel");
  394.             break;
  395.         case 7:
  396.             pd->type='f';
  397.             pd->data=&angulardamp;
  398.             strcpy(pd->name,"angulardamp");
  399.             break;
  400.         case 8:
  401.             pd->type='3';
  402.             pd->data=&objmesh;
  403.             strcpy(pd->name,"objmesh");
  404.             break;
  405.         case 9:
  406.             pd->type='3';
  407.             pd->data=&shieldmesh;
  408.             strcpy(pd->name,"shieldmesh");
  409.             break;
  410.         case 10:
  411.             pd->type=TYPE_EXPLODE;
  412.             pd->data=&exp;
  413.             strcpy(pd->name,"explode");
  414.             break;
  415.         case 11:
  416.             pd->type='i';
  417.             pd->data=&exptime;
  418.             strcpy(pd->name,"exptime");
  419.             break;
  420.         case 12:
  421.             pd->type='i';
  422.             pd->data=&maxabtime;
  423.             strcpy(pd->name,"maxabtime");
  424.             break;
  425.         case 13:
  426.             pd->type=TYPE_LIGHT;
  427.             pd->data=&englight;
  428.             strcpy(pd->name,"englight");
  429.             break;
  430.         case 14:
  431.             pd->type=TYPE_SPRITE_LIGHT;
  432.             pd->data=&enghalo;
  433.             strcpy(pd->name,"enghalo");
  434.             break;
  435.         case 15:
  436.             pd->type='f';
  437.             pd->data=&engpos;
  438.             strcpy(pd->name,"engpos");
  439.             break;
  440.         case 16:
  441.             pd->type=TYPE_SPOT_LIGHT;
  442.             pd->data=&spot;
  443.             strcpy(pd->name,"spot");
  444.             break;
  445.         case 17:
  446.             pd->type='f';
  447.             pd->data=&mousespeed;
  448.             strcpy(pd->name,"mousespeed");
  449.             break;
  450.         case 18:
  451.             pd->type='f';
  452.             pd->data=&forcefactor;
  453.             strcpy(pd->name,"forcefactor");
  454.             break;
  455.         case 19:
  456.             pd->type='c';
  457.             pd->data=&hitcolor;
  458.             strcpy(pd->name,"hitcolor");
  459.             break;
  460.         case 20:
  461.             pd->type='c';
  462.             pd->data=&invencolor;
  463.             strcpy(pd->name,"invencolor");
  464.             break;
  465.         case 21:
  466.             pd->type='c';
  467.             pd->data=&killcolor;
  468.             strcpy(pd->name,"killcolor");
  469.             break;
  470.         case 22:
  471.             pd->type='f';
  472.             pd->data=&invistransp;
  473.             strcpy(pd->name,"invistransp");
  474.             break;
  475.         case 23:
  476.             pd->type='i';
  477.             pd->data=&ng;
  478.             strcpy(pd->name,"nguns");
  479.             break;
  480.         case 24:
  481.             pd->type=TYPE_GUN;
  482.             pd->data=&g[0];
  483.             strcpy(pd->name,"gun1");
  484.             break;
  485.         case 25:
  486.             pd->type=TYPE_GUN;
  487.             pd->data=&g[1];
  488.             strcpy(pd->name,"gun2");
  489.             break;
  490.         case 26:
  491.             pd->type=TYPE_GUN;
  492.             pd->data=&g[2];
  493.             strcpy(pd->name,"gun3");
  494.             break;
  495.         case 27:
  496.             pd->type=TYPE_GUN;
  497.             pd->data=&g[3];
  498.             strcpy(pd->name,"gun4");
  499.             break;
  500.         case 28:
  501.             pd->type=TYPE_GUN;
  502.             pd->data=&g[4];
  503.             strcpy(pd->name,"gun5");
  504.             break;
  505.         case 29:
  506.             pd->type=TYPE_GUN;
  507.             pd->data=&g[5];
  508.             strcpy(pd->name,"gun6");
  509.             break;
  510.         case 30:
  511.             pd->type=TYPE_GUN;
  512.             pd->data=&g[6];
  513.             strcpy(pd->name,"gun7");
  514.             break;
  515.         case 31:
  516.             pd->type=TYPE_GUN;
  517.             pd->data=&g[7];
  518.             strcpy(pd->name,"gun8");
  519.             break;
  520.         case 32:
  521.             pd->type=TYPE_GUN;
  522.             pd->data=&g[8];
  523.             strcpy(pd->name,"gun9");
  524.             break;
  525.     }
  526.     return 0;
  527. }
  528.  
  529. void ship::check_keys(int time_step)
  530. {
  531.     static int lastmouse[2][2]={ { 0,0 },{ 0,0 } },lm=0;
  532.     float mousedx=(directx->dims.lX+lastmouse[0][0]+lastmouse[1][0])/3.0f;
  533.     float mousedy=(directx->dims.lY+lastmouse[0][1]+lastmouse[1][1])/3.0f;
  534.     lastmouse[lm][0]=directx->dims.lX;
  535.     lastmouse[lm][1]=directx->dims.lY;
  536.     lm=!lm;
  537.  
  538.     unsigned char *diks=directx->diks;
  539.         
  540.     if (diks[0x38])
  541.         {
  542.         if (diks[0xcb])
  543.             force-=X/forcefactor;
  544.         if (diks[0xcd])
  545.             force+=X/forcefactor;
  546.         if (diks[0xc8])
  547.             force+=Y/forcefactor;
  548.         if (diks[0xd0])
  549.             force-=Y/forcefactor;
  550.         }
  551.     else
  552.         {
  553.         if (diks[0xcb])
  554.             rotforce.y+=1;
  555.         if (diks[0xcd])
  556.             rotforce.y-=1;
  557.         if (diks[0xc8])
  558.             rotforce.x-=1;
  559.         if (diks[0xd0])
  560.             rotforce.x+=1;
  561.         }
  562.  
  563.     if (diks[0x1e])
  564.         rotforce.z+=1;
  565.     if (diks[0x20])
  566.         rotforce.z-=1;
  567.  
  568.     if (diks[0x11])
  569.         if ((flag&0x1000)==0)
  570.             flag^=0x1100;
  571.         else ;
  572.     else if (flag&0x1000)
  573.             flag^=0x1000;
  574.  
  575.     if (diks[0x10])
  576.         force-=X/forcefactor;
  577.     if (diks[0x12])
  578.         force+=X/forcefactor;
  579.  
  580.     if (diks[0x1f] || diks[0x3A])
  581.         force-=Z/forcefactor;
  582.     if (diks[0x2d])
  583.         force+=Z/forcefactor;
  584.  
  585.     if (diks[0x3A])
  586.         {
  587.         if (abtime>0)
  588.             {
  589.             speedboost=speedboost0;
  590.             abtime-=time_step;
  591.             flag|=0x10;
  592.             }
  593.         else 
  594.             {
  595.             abtime=0;
  596.             speedboost=0.0f;
  597.             flag&=0xff0f;
  598.             }
  599.         }
  600.     else 
  601.         {
  602.         abtime+=time_step/4;
  603.         if (abtime>maxabtime)
  604.             abtime=maxabtime;
  605.         speedboost=0.0f;
  606.         flag&=0xff0f;
  607.         }
  608.  
  609.     if (diks[0x38])
  610.         {
  611.         if (mousedx>4)
  612.             force+=X/forcefactor;
  613.         else if (mousedx<-4)
  614.             force-=X/forcefactor;
  615.  
  616.         if (mousedy>4)
  617.             force-=Y/forcefactor;
  618.         else if(mousedy<-4)
  619.             force+=Y/forcefactor;
  620.         }
  621.     else
  622.         {
  623.         mouserot.y=-mousedx/mousespeed;
  624.         mouserot.x=mousedy/mousespeed;
  625.         }
  626.  
  627.     int i;
  628.     for( i=0;i<9;i++ )
  629.         if (directx->diks[2+i])
  630.             {
  631.             firesel=i;
  632.             break;
  633.             }
  634.     if (g[firesel])
  635.     if (directx->diks[0x9d] || directx->diks[0x39] || 
  636.         directx->dims.rgbButtons[0])
  637.         if (g[firesel]->fire_status())
  638.             if (directx->mpmode==FLYMP_NOMP)
  639.                 g[firesel]->fire(this,player);
  640.             else mp_send_pos(FLYMP_MSG_POS,flag|firesel|(points<<16));
  641. }
  642.  
  643. void ship::draw_game_status()
  644. {
  645.     static char str[256];
  646.     int i,j,k;
  647.  
  648.     tc->use(display);
  649.     glBegin(GL_QUADS);
  650.         glTexCoord2f(0,1);
  651.         glVertex2i(0,0);
  652.         glTexCoord2f(0.375f,1);
  653.         glVertex2i(48,0);
  654.         glTexCoord2f(0.375f,0);
  655.         glVertex2i(48,128);
  656.         glTexCoord2f(0,0);
  657.         glVertex2i(0,128);
  658.     glEnd();
  659.  
  660.     tc->use(-1);
  661.     glBegin(GL_QUADS);
  662.         glColor4ub(153,255,178,255);
  663.         j=18+(int)(104.0f*abtime/maxabtime);
  664.         glVertex2i(5,18);
  665.         glVertex2i(16,18);
  666.         glVertex2i(16,j);
  667.         glVertex2i(5,j);
  668.     
  669.         glColor4ub(40,40,255,255);
  670.         j=18+(int)(104*shield/maxshield);
  671.         glVertex2i(31,18);
  672.         glVertex2i(42,18);
  673.         glVertex2i(42,j);
  674.         glVertex2i(31,j);
  675.     glEnd();
  676.     
  677.     for( i=0;i<directx->nplayers;i++)
  678.         {
  679.         sprintf(str,"%s (%i)",directx->players[i].name,((ship *)directx->players[i].data)->points);
  680.         flyengine->draw_text( 0, i*16, str );
  681.         }
  682.     k=screen_sy-16;
  683.     j=screen_sx/2;
  684.     for( i=0;i<ng;i++,j+=32 )
  685.         {
  686.         if (g[i])
  687.             if (firesel==i)
  688.                 sprintf(str,"[%i]",g[i]->firecount);
  689.             else sprintf(str,"%i",g[i]->firecount);
  690.         flyengine->draw_text( j, k, str );
  691.         }
  692.     static DWORD t=timeGetTime();
  693.     static int frame_rate=0,frame_count=0;
  694.     frame_count++;
  695.     if (flyengine->cur_time-t>1000)
  696.         {
  697.         frame_rate=frame_count*1000/(flyengine->cur_time-t);
  698.         t=flyengine->cur_time;
  699.         frame_count=0;
  700.         }
  701.     if (flyengine->cur_time - flyengine->status_msg_time > 2000)
  702.         {
  703.         sprintf(str,"FPS:%i N:%i",frame_rate,flyengine->nodedrawcount);
  704.         flyengine->draw_text( screen_sx-96, 0, str );
  705.         }
  706. }
  707.  
  708. void ship::mp_send_pos(int msgtype,int msgflag)
  709. {
  710.     static struct mp_data data;
  711.     
  712.     data.type=msgtype;
  713.     data.dpid=directx->players[player].dpid;
  714.     data.flag=msgflag;
  715.     data.pos=pos;
  716.     data.vel=vel;
  717.     data.Y=Y;
  718.     data.Z=Z;
  719.  
  720.     directx->send_message((mp_msg *)&data,sizeof(struct mp_data));
  721. }
  722.  
  723. mesh *ship::ray_intersect(vector& ro,vector& rd,vector& ip,float& dist,int &facenum,float rad)
  724. {
  725.     if (shieldmesh)
  726.     {
  727.         static float d1,d2;
  728.         vector 
  729.             ro_local=(ro-pos)*mat_t,
  730.             rd_local=rd*mat_t;
  731.         if (shieldmesh->bbox.ray_intersect(ro_local,rd_local,d1,d2))
  732.         {
  733.         facenum=shieldmesh->ray_intersect(ro_local,rd_local,ip,dist,rad);
  734.         if (facenum>-1)
  735.             {
  736.             if (directx->mpmode!=FLYMP_CLIENT && (flag3&0x20000)==0 && flyengine->stepobj 
  737.                 && (flyengine->stepobj->type==TYPE_LASER || flyengine->stepobj->type==TYPE_MISSILE) 
  738.                 && dist<1.0f && ((gun_projectile *)flyengine->stepobj)->damage>0.0f)
  739.                     {
  740.                     shield-=((gun_projectile *)flyengine->stepobj)->damage;
  741.                     lasthittime=flyengine->cur_time;
  742.                     if (directx->mpmode==FLYMP_SERVER)
  743.                         {
  744.                         mp_data2 msg;
  745.                         msg.f=((gun_projectile *)flyengine->stepobj)->damage;
  746.                         msg.v=vel;
  747.                         msg.type=FLYMP_MSG_DAMAGE;
  748.                         msg.from=directx->players[player].dpid;
  749.                         directx->send_message((mp_msg *)&msg,sizeof(mp_data2));
  750.                         }
  751.                     }
  752.             ip=ip*mat+pos;
  753.             return shieldmesh;
  754.             }
  755.         }
  756.     }
  757.     return 0;
  758. }
  759.